package com.job.client.company.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.job.client.common.result.AppHttpCode;
import com.job.client.common.result.ResponseResult;
import com.job.client.company.mapper.CategoryMapper;
import com.job.client.company.service.CategoryService;
import com.job.client.model.company.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 职位分类表 服务实现类
 * </p>
 *
 * @author fkl
 * @since 2023-12-07
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public ResponseResult getCategoryName(String categoryId) {
        if(categoryId == null){
            return ResponseResult.ErrorResult(AppHttpCode.DATA_NULL);
        }
        Category category = categoryMapper.selectById(categoryId);
        return ResponseResult.OkResult(category.getName());
    }

    @Override
    public ResponseResult getCategoryList() {
        List<Category> categoryList = categoryMapper.selectList(null);
        if(categoryList == null){
            return ResponseResult.ErrorResult(AppHttpCode.SERVICE_ERROR);
        }
        return ResponseResult.OkResult(categoryList);
    }
}
